# Contributor: Stuart Cardall <developer@it-offshore.co.uk>
# Maintainer: Stuart Cardall <developer@it-offshore.co.uk>
pkgname=firejail
pkgver=0.9.62.4
pkgrel=0
pkgdesc="Linux namespaces and seccomp-bpf sandbox"
url="https://firejail.wordpress.com/"
arch="all"
license="GPL-2.0-only"
depends="bash"
makedepends="linux-headers"
checkdepends="expect"
options="suid"
subpackages="$pkgname-doc $pkgname-bash-completion:bashcomp:noarch"
source="firejail-$pkgver.tar.gz::https://github.com/netblue30/firejail/archive/$pkgver.tar.gz"

prepare() {
	default_prepare

	find "$builddir" -name Makefile.in -exec sed -i -r \
		-e '/CFLAGS/s: (-O2|-ggdb) : :g' \
		-e '1iCC=@CC@' {} +
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-busybox-workaround
	make
}

bashcomp() {
	pkgdesc="Bash completions for $pkgname"
	depends="bash"
	install_if="$pkgname=$pkgver-r$pkgrel bash-completion"

	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/share "$subpkgdir"/usr/
}

check() {
	make test
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="24b1321809d4246e6d668756179b162e04b1310b74e3ca39c4392ea6689031cb02aa6718decd943de2d3f48ff15420d9d54f7e8e7cd2bb9454aab97fa0ed8fcf  firejail-0.9.62.4.tar.gz"
